package com.li.system.controller.question;


import com.li.common.core.controller.BaseController;
import com.li.common.core.domain.R;
import com.li.common.core.domain.TableDataInfo;
import com.li.system.domain.question.dto.QuestionAddDTO;
import com.li.system.domain.question.dto.QuestionEditDTO;
import com.li.system.domain.question.dto.QuestionQueryDTO;
import com.li.system.domain.question.vo.QuestionDetailVO;
import com.li.system.service.quesstion.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("question")
@Tag(name = "题目管理")
public class QuestionController extends BaseController  {

    @Autowired
    private IQuestionService questionService;

    //获取题目列表
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return getTableDataInfo(questionService.list(questionQueryDTO));
    }

    //添加题目
    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toR(questionService.add(questionAddDTO));
    }


    //获取题目详情
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId) {
        return R.ok(questionService.detail(questionId));
    }

    //编辑题目
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toR(questionService.edit(questionEditDTO));
    }

    //删除题目
    @DeleteMapping("/delete")
    public R<Void> delete(@RequestParam Long questionId){
        return toR(questionService.delete(questionId));
    }


}
